﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ajayumi.develop.win32.Transport.AppUpgrade.Controls
{
    public partial class UcBase : UserControl
    {

        #region variable

        /// <summary>
        /// 上一步的窗体
        /// </summary>
        protected UcBase m_PreControl;
        /// <summary>
        /// 下一步的窗体
        /// </summary>
        protected UcBase m_NextControl;

        /// <summary>
        /// 设置按钮可见状态
        /// </summary>
        public Action<WizardFormButtons> SetButtonVisible;

        #endregion

        #region property

        public string Title { get; set; }

        #endregion


        public UcBase()
            : this(null)
        {
            InitializeComponent();
        }

        public UcBase(UcBase preControl)
        {
            InitializeComponent();
            m_PreControl = preControl;

            InitDefaultValue();
        }

        #region method

        protected virtual void InitDefaultValue()
        {

        }

        /// <summary>
        /// 模拟实现上一步
        /// </summary>
        protected virtual void PerformBack()
        {
            WizardForm wizrdForm = this.FindForm() as WizardForm;
            wizrdForm.PerformBack();
        }


        /// <summary>
        /// 模拟实现下一步
        /// </summary>
        protected virtual void PerformNext()
        {
            WizardForm wizrdForm = this.FindForm() as WizardForm;
            wizrdForm.PerformNext();
        }

        internal virtual UcBase Back()
        {
            return this.m_PreControl;
        }

        internal virtual UcBase Next()
        {
            return this.m_NextControl;
        }

        /// <summary>
        /// 还原
        /// </summary>
        internal virtual void Restore()
        { }

        /// <summary>
        /// 升级
        /// </summary>
        internal virtual void Upgrade()
        { }

        /// <summary>
        /// 取消
        /// </summary>
        internal virtual void Cancel()
        { }

        /// <summary>
        /// 应用程序退出
        /// </summary>
        internal virtual void AppExit()
        { }

        #endregion
    }
}
